package com.example.makerspace.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.makerspace.domain.IntegralTasksDO;
import com.example.makerspace.mapper.IntegralTasksMapper;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

@Component
public class IntegralTasksDAO extends  BaseDAO<IntegralTasksDO>{

    @Resource
    private IntegralTasksMapper  integralTasksMapper;
    @PostConstruct
    public void init(){
        this.mapper = integralTasksMapper;
    }

    public List<IntegralTasksDO> selectByUserName(String username) {
        QueryWrapper<IntegralTasksDO> wrapper = new QueryWrapper<>();
        wrapper.eq("username",username);
        return mapper.selectList(wrapper);
    }

    public IntegralTasksDO selectByProductTaskName(String username) {
        QueryWrapper<IntegralTasksDO> wrapper = new QueryWrapper<>();
        wrapper.eq("task_name","上架产品").eq("username",username).eq("is_finish",0);
        return mapper.selectOne(wrapper);
    }


    public IntegralTasksDO selectByUserTaskName(String username) {
        QueryWrapper<IntegralTasksDO> wrapper = new QueryWrapper<>();
        wrapper.eq("task_name","个人认证").eq("username",username).eq("is_finish",0);
        return mapper.selectOne(wrapper);
    }

    public IntegralTasksDO selectByEntTaskName(String username) {
        QueryWrapper<IntegralTasksDO> wrapper = new QueryWrapper<>();
        wrapper.eq("task_name","企业认证").eq("username",username).eq("is_finish",0);
        return mapper.selectOne(wrapper);
    }
}
